package com.order.controller;

import com.dto.GoodsDto;
import com.dto.api.GoodsApi;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import java.util.List;

@RestController
public class OrderController {

    private final RestTemplate restTemplate;

    private final GoodsApi goodsApi;

    public OrderController(RestTemplate restTemplate, GoodsApi goodsApi) {
        this.restTemplate = restTemplate;
        this.goodsApi = goodsApi;
    }


    @GetMapping("/hello")
    public String hello(){
        return "我要买买买："+restTemplate.getForObject("http://goods-service/buyOne",String.class);
    }

    @GetMapping("/orderWithGoodsInfo")
    public List<GoodsDto> orderWithGoodsInfo(){
        return goodsApi.page("test");
    }
}
